package com.pan.kang.demo.controller;

import com.pan.kang.demo.application.OrderApplication;
import com.pan.kang.demo.dto.CancelOrderDto;
import com.pan.kang.demo.dto.CustomInfoDto;
import com.pan.kang.demo.res.Request;
import com.pan.kang.demo.res.Response;
import com.pan.kang.demo.util.ResultUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

@RestController
@RequestMapping("/app/order")
public class OrderController {

    @Autowired
    private OrderApplication orderApplication;


    @PostMapping("/V1.0/customCreate")
    public Response<String> customCreate(@Valid @RequestBody Request<CustomInfoDto> requestBean) {
        return ResultUtils.construct(orderApplication.customCreate(requestBean.getData()));
    }


    @PostMapping("/V1.0/cancel")
    public Response<Boolean> cancel(@Valid @RequestBody Request<CancelOrderDto> requestBean) {
        return ResultUtils.construct(orderApplication.cancelOrder(requestBean.getData()));
    }
}
